using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;

namespace ClientTools.Client.Library.Provider
{
    public sealed class ProviderManager
    {
        private static ProviderInfoCollection _ProviderInfos = null;

        public static ProviderInfoCollection ProviderInfos
        {
            get
            {
                if (_ProviderInfos == null)
                {
                    _ProviderInfos = new ProviderInfoCollection();

                    foreach (Type t in Assembly.GetExecutingAssembly().GetTypes())
                    {
                        Type i = t.GetInterface(typeof(Interfaces.IProvider).Name);
                        if (i != null)
                        {
                            ProviderInfo pi = new ProviderInfo();
                            pi.ProviderName = ((Interfaces.IProvider)Activator.CreateInstance(t)).Providername;
                            pi.ProviderType = t;
                            _ProviderInfos.Add(pi);
                        }
                    }
                }
                return _ProviderInfos;
            }
        }
    }
}
